//
//  XMSOSSpinLock.m
//  
//
//  Created by wjxfhxy on 16/5/10.
//
//

#import "XMSOSSpinLock.h"

#import <libkern/OSAtomic.h>

@implementation XMSOSSpinLock
{
    OSSpinLock _lock;
}

-(instancetype)init
{
    self = [super init];
    
    _lock = OS_SPINLOCK_INIT;
    
    return self;
}

- (void)lock:(void(^)())block
{
    OSSpinLockLock(&_lock);
    
    block();
    
    OSSpinLockUnlock(&_lock);
}

-(void)dealloc
{
    superdealloc_mm;
}

@end
